﻿@model TS2015.Models.SendMail

<div class="panel">
    <div class="panel-body">

        @using (Ajax.BeginForm("SendMail", "QLHeThong", new AjaxOptions() { HttpMethod = "POST" }, new { enctype = "multipart/form-data" }))
        {
            @Html.ValidationSummary(true)
            @Html.AntiForgeryToken()

            <div class="form-group">
                <label>Máy chủ mail:</label>
                @Html.DropDownListFor(m => m.ID, (SelectList)ViewBag.TbMailServer, new { @class = "form-control" })
                
                @Html.ValidationMessageFor(m => m.ID)
            </div>

            <div class="form-group">
                <label>Người nhận:</label>
                @Html.TextBoxFor(e => e.NguoiNhan, new { @class = "form-control", placeholder = "Nhập địa chỉ mail người nhận (nếu nhiều địa chỉ tách nhau bằng dấu ',')" })
                @Html.ValidationMessageFor(m => m.NguoiNhan)
            </div>
            <div class="form-group">
                <label>Chủ đề:</label>
                @Html.TextBoxFor(e => e.ChuDe, new { @class = "form-control", placeholder = "Nhập chủ đề" })
                @Html.ValidationMessageFor(m => m.ChuDe)
            </div>
            <div class="form-group">
                <label>Nội dung:</label>
                @Html.TextAreaFor(e => e.NoiDung, new { @class = "form-control", id = "NoiDung", placeholder = "Nội dung" })
                @Html.ValidationMessageFor(m => m.NoiDung)
            </div>
            <div class="form-group">
                <label>Đính kèm:</label>
                @*@Html.TextBoxFor(e => e.Attachments, new { @class = "form-control", type = "file" })
                    @Html.ValidationMessageFor(m => m.Attachments)*@
                <input name="Attachments" type="file" multiple="multiple" />
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-danger">Gửi</button>
            </div>
        }
    </div>

    <div id="status"></div>
</div>
<script src="~/Content/tinymce/tinymce.min.js"></script>
<script src="~/Scripts/jquery.form.min.js"></script>

<script type="text/javascript">
    (function ()
    {

        //var bar = $('.progress-bar');
        //var percent = $('.progress-bar');
        //var status = $('#status');

        $('form').ajaxForm({
            beforeSend: function ()
            {
                //status.empty();
                //var percentVal = '0%';
                //bar.width(percentVal)
                //percent.html(percentVal);
                $('#loading-icon').show();
            },
            //uploadProgress: function (event, position, total, percentComplete)
            //{
            //    var percentVal = percentComplete + '%';
            //    bar.width(percentVal)
            //    percent.html(percentVal);
            //},
            success: function ()
            {
                //alert("Success");
                //var percentVal = '100%';
                //bar.width(percentVal)
                //percent.html(percentVal);
            },
            complete: function (xhr)
            {
                if (xhr.responseText == 'true')
                {
                    var notification = $("#notification").kendoNotification().data("kendoNotification");
                    notification.show("Thực hiện thao tác thành công.", "info");
                    $('form').trigger("reset");
                }
                $("#loading-icon").hide();
            }
        });

    })();


    tinymce.init({
        selector: "textarea#NoiDung",
        theme: "modern",
        //width: 300,
        height: 300,
        language: 'vi_VN',
        fontsize_formats: "8pt 9pt 10pt 11pt 12pt 13pt 14pt 15pt 16pt 18pt 24pt 36pt",
        plugins: [
             "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
             "save table contextmenu directionality emoticons template paste textcolor"
        ],
        //content_css: "css/content.css",
        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify |" +
        "bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons | fontselect | fontsizeselect",
        style_formats: [
             { title: 'Bold text', inline: 'b' },
             { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
             { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } },
             { title: 'Example 1', inline: 'span', classes: 'example1' },
             { title: 'Example 2', inline: 'span', classes: 'example2' },
             { title: 'Table styles' },
             { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
        ]
    });
</script>
